<template>
  <div>
    <div>
      <el-form :model="queryParams" ref="queryForm" size="small" :inline="true">
        <el-form-item>
          <el-button type="primary" icon="el-icon-search" size="mini" @click="paramId=0,zhudianVisible=true" plain>
            新增所属执勤点
          </el-button>
          <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
        </el-form-item>
      </el-form>
      <el-table v-loading="loading" :data="teamlist" size="small">
        <el-table-column label="执勤点名称" align="center" prop="name"/>
        <el-table-column
          label="所在地区"
          align="center"
          prop="inAddress"
        />
        <el-table-column
          prop="type"
          label="执勤点类型"
          width="100"
        >
          <template slot-scope="scope">
            <dict-tag
              :options="dict.type.sys_stagnation_type"
              :value="scope.row.type"
            />
          </template>
        </el-table-column>
        <el-table-column
          label="创建时间"
          align="center"
          prop="createTime"
        />
        <el-table-column
          label="操作"
          align="center"
          class-name="small-padding fixed-width"
        >
          <template slot-scope="scope">
            <el-button
              size="mini"
              type="text"
              icon="el-icon-view"
              @click="handleView(scope.row)"
              v-hasPermi="['system:stagnation_point:query']"
            >详情
            </el-button>
            <el-button
              size="mini"
              type="text"
              icon="el-icon-edit"
              @click="handleUpdate(scope.row)"
              v-hasPermi="['system:stagnation_point:edit']"
            >编辑
            </el-button
            >
<!--            <el-button-->
<!--              size="mini"-->
<!--              type="text"-->
<!--              icon="el-icon-view"-->
<!--              @click="handleViewTeam(scope.row)"-->
<!--              v-hasPermi="['system:team:list']"-->
<!--            >查看执勤点人员-->
<!--            </el-button-->
<!--            >-->
          </template>
        </el-table-column>
      </el-table>
    </div>
    <zhudianAdd :visible.sync="zhudianVisible" :paramDept="projectData" @getList="getList" :paramId="paramId"></zhudianAdd>
    <zhudianTeam :visible.sync="teamVisible" :param="paramPoint"></zhudianTeam>
  </div>
</template>

<script>
import {listStagnationPoint} from "@/api/system/stagnation_point";
import zhudianAdd from "@/components/zhudian//add"
import zhudianTeam from "@/components/zhudian-team/index"

export default {
  name: "index",
  props: ['paramId', 'projectData'], // param 执勤点信息
  dicts: ['sys_stagnation_type'],
  components: {zhudianAdd, zhudianTeam},
  data() {
    return {
      teamlist: [],
      title: '项目执勤点信息',
      // 遮罩层
      loading: true,
      queryParams: {
        pageNum: 1,
        pageSize: 50,
        projectId: this.paramId
      },
      zhudianVisible: false,
      teamVisible: false,
      paramPoint: null
    }
  },
  watch: {
  },
  created() {
    this.getList()
  },
  methods: {
    /** 查询定位器列表 */
    getList() {
      this.loading = true;
      listStagnationPoint(this.queryParams).then(response => {
        this.teamlist = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 查看执勤点人员*/
    handleViewTeam(row) {
      this.paramPoint = JSON.parse(JSON.stringify(row))
      this.teamVisible = true
    },
    /** 编辑 */
    handleUpdate(row) {
      this.paramId = row.id
      this.zhudianVisible = true
    },
    handleView(row) {
      this.$router.push(`/stagnation_point/detail/index/${row.id}`)
    },
  }
}
</script>

<style scoped>

</style>
